var t = getApp();

Page({
    data: {
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1,
        activeName: 0,
        details: {}
    },
    onLoad: function(t) {
        this.getDetails(), this.getListData();
    },
    tabChange: function(t) {
        this.setData({
            activeName: t.detail.index
        }), this.getListData();
    },
    onReady: function() {},
    onShow: function() {},
    getDetails: function() {
        var a = this, e = t.getNetAddresss("plugin.appointment.frontend.income.index");
        t._getNetWork({
            url: e,
            success: function(e) {
                var i = e.data;
                if (1 != i.result) return t.tips(i.msg);
                a.setData({
                    details: i.data
                });
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? (console.log("111111111111111"), this.getMoreData()) : console.log("没有更多数据");
    },
    initPage: function() {
        this.setData({
            listData: [],
            networkLoading: !1
        }), this.data.page = 1, this.data.total_page = 0, this.data.isLoadMore = !0;
    },
    getListData: function() {
        var a = this;
        this.initPage();
        var e = t.getNetAddresss("plugin.appointment.frontend.income.get-list"), i = {
            page: this.data.page,
            income_type: this.data.activeName
        };
        t._getNetWork({
            url: e,
            data: i,
            success: function(e) {
                var i = e.data;
                if (1 != i.result) return t.tips(i.msg);
                a.setData({
                    isLoadMore: !0,
                    total_page: i.data.last_page,
                    listData: i.data.data,
                    networkLoading: !0
                }), a.data.total_page || (a.data.total_page = 0);
            }
        });
    },
    getMoreData: function() {
        var a = this, e = t.getNetAddresss("plugin.appointment.frontend.income.get-list");
        if (this.data.isLoadMore = !1, this.data.page >= this.data.total_page) console.log("111111111111111", this.data.page, this.data.total_page); else {
            this.data.page++;
            var i = {
                page: this.data.page,
                income_type: this.data.activeName
            };
            t._getNetWork({
                url: e,
                data: i,
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        a.data.isLoadMore = !0;
                        var i = e.data.data;
                        a.setData({
                            listData: a.data.listData.concat(i)
                        });
                    } else a.data.isLoadMore = !1, a.data.page--;
                }
            });
        }
    },
    onShareAppMessage: function() {}
});